<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue路由5</title>
    <script src="../../js/vue3.js"></script>
    <script src="../../js/vue-router.global.js"></script>
    <style>
        #app {
            margin: 5rem auto;
            width: 35%;
        }
        
        * {
            padding: 0;
            margin: 0;
        }
        
        .box {
            border: 1px gray solid;
        }
        
        .row {
            display: flex;
            justify-content: space-around;
        }
        
        .row>a {
            width: 50%;
            background-color: lightgray;
            border: 1px gray solid;
            font-size: 1.2rem;
            text-align: center;
            padding: 1rem;
        }
        
        .contents {
            height: 7rem;
            padding: 1rem;
            font-size: 1.5rem;
        }
        
        .row>.router-link-active {
            background-color: brown;
            color: white;
        }
    </style>
</head>

<body>
    <!-- 运行 -->
    <div id="app">
        <div class="box">
            <div class="row">
                <router-link to="/news">新闻咨询</router-link>
                <router-link to="/relate">联系方式</router-link>
            </div>
            <div class="contents">
                <router-view></router-view>
            </div>
        </div>

    </div>
    <!-- 模版 -->
    <template id="news">
        <p><router-link to="/news/content">河北科工大</router-link></p> 
        <p><router-view></router-view></p>
    </template>
    <template id="relate">
        <p>联系方式:114514</p>
    </template>
    <template id="content">
       <p>识佛得分高收费刚发ID时间刚发发给房管局啊十几个撒娇咖啡机啊</p>
    </template>
    <script>
        const v_app = Vue.createApp({
            data() {
                return {

                }
            },
        });
        const news = {
            template: "#news",
        }
        const relate = {
            template: "#relate",
        }
        const content = {
            template: "#content",
        }
        const routes = [{
            path: "/news",
            component: news,
            children:[
                {
                path: "content",
                component: content
            }
        ]
        }, {
            path: "/relate",
            component: relate
        },]
        const router = VueRouter.createRouter({
            history: VueRouter.createWebHashHistory(),
            routes: routes
        });
        v_app.use(router);
        v_app.mount("#app");
    </script>
</body>

</html>